package com.wise.service.cms.content.advice;

import com.wise.entities.content.SearchAdvice;
import com.wise.framework.daomodel.DaoSave;
import com.wise.summer.v1.cms.content.advice.AddAdvice;
import org.springframework.stereotype.Service;
import org.summerframework.model.SummerService;
import org.summerframework.model.SummerServiceBean;

/**
 * 添加推荐搜索关键字-链接
 *
 * @author Haoming Chen
 * Created on 2019/11/14
 */
@Service
@SummerService
public class AddAdviceService implements SummerServiceBean<AddAdvice> {

    @Override
    public void sum(AddAdvice model) {

        /* 默认值:
           sort: 50
           isDelete: false
           creationDate: DateTimeUtil.timestampNow()
           createdBy: CurrentUserId
           */
        SearchAdvice searchAdvice = SearchAdvice.createSearchAdvice();
        searchAdvice.setIsActivate(model.getIsActivate() == 1 ? true : false);
        searchAdvice.setKeyword(model.getKeyword());
        searchAdvice.setUri(model.getUri());
        if (model.getSort() != null) {
            searchAdvice.setSort(model.getSort());
        }
        DaoSave.s(searchAdvice);
        model.setSummerResult(true);

    }

}
